import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'


export const constantRoutes = [

  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/mindex',
    component: () => import('@/views/error-page/mindex'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: '首页', icon: 'dashboard', affix: true }
      }
    ]
  },
 
 
  {
    path: '/sys_management',
    component: Layout,
    // redirect: '/system_management/list',
    name: 'Permission',
    meta: {
      title: '系统管理',
      icon: 'lock',
      
    },
    children: [
       {
        path: '/members_management',
        component: () => import('@/views/system/user/list'),
        name: 'user',
        meta: {
          title: '用户管理',
         
        }
      },
      {
        path: '/customer_success',
        // redirect: '/roles/list',
        component: () => import('@/views/system/team/list'),
        name: 'team',
        meta: {
          title: '客户成功管理',
         
        }
      },
      {
        path: '/customer_detail',
        // redirect: '/roles/list',
        component: () => import('@/views/system/team/team_province'),
        name: 'customer_province',
        meta: {
          title: '客户成功管理/子团队管理',
          activeMenu: '/customer_success' 
         
        }
      },
      {
        path: '/roles_management',
        // redirect: '/roles/list',
        component: () => import('@/views/system/role/list'),
        name: 'role',
        meta: {
          title: '角色管理',
         
        }
      },
      {
        path: '/region_management',
        // redirect: '/roles/list',
        component: () => import('@/views/system/region/list'),
        name: 'region',
        meta: {
          title: '战区',
         
        }
      },
     
      {
        path: '/region_detail',
        // redirect: '/roles/list',
        component: () => import('@/views/system/region/region_province'),
        name: 'region_province',
        meta: {
          title: '战区管理/战区省份',
          activeMenu: '/region_management' 
         
        }
      }
      // 
    ]
  },
  
  {
    path: '/base_data',
    component: Layout,
   
    name: 'baseData',
    meta: {
      title: '驾驶舱数据',
      icon: 'el-icon-s-help'
    },
    children: [
        {
        path: '/cockpit/base_data/business_opportunities',
        component: () => import('@/views/base_data/business_opportunities'),
        name: 'business_opportunities',
        meta: { title: '商机数据' }
       
      },
      {
        path: '/cockpit/base_data/expenses',
        component: () => import('@/views/base_data/expenses'),
        name: 'expenses',
        meta: { title: '支出数据' }
       
      },
      {
        path: '/cockpit/base_data/new_sign',
        component: () => import('@/views/base_data/new_sign'),
        name: 'new_sign',
        meta: { title: '新签数据' }
       
      },
      {
        path: '/cockpit/base_data/payment_collections',
        component: () => import('@/views/base_data/payment_collections'),
        name: 'payment_collections',
        meta: { title: '回款数据' }
       
      },
      // GET /api/personnelCosts
      {
        path: '/cockpit/base_data/personnel_costs',
        component: () => import('@/views/base_data/personnel_costs'),
        name: 'personnel_costs',
        meta: { title: '人员成本' }
       
      },
      
    ]
  },
  {
    path:'/cockpit',
    component:Layout,
    name:'cockpit',
    meta: {
      title: '驾驶舱',
      icon: 'el-icon-s-help'
    },
    children: [
        {
        path: '/cockpit/province',
        component: () => import('@/views/province_jsc/index'),
        name: 'cockpit_province',
        meta: { title: '驾驶舱省数据' }
       
      },
      {
        path: '/cockpit/region',
        component: () => import('@/views/region_jsc/index'),
        name: 'cockpit_province',
        meta: { title: '驾驶舱战区数据' }
       
      },
      {
        path: '/cockpit/admin',
        component: () => import('@/views/admin_jsc/index'),
        name: 'cockpit_province',
        meta: { title: '驾驶舱管理员数据' }
       
      },
    ]
  },

  {
    path: '/product',
    component: Layout,
    // redirect: '/product/polist',
    name: 'Product',
    meta: {
      title: '生产进度管理',
      icon: 'excel'
    },
    children: [
      {
        path: '/po_management_list',
        component: () => import('@/views/product/list'),
        name: 'Polist',
        meta: { title: 'PO管理列表' }
      },
      {
        path: '/po_detail',
        component: () => import('@/views/product/components/poInfoDetail'),
        name: 'PolistDetail',
        meta: { title: 'PO管理详情',activeMenu:'/po_management_list' }
      },
      {
        path: '/po_course_supplier',
        component: () => import('@/views/product/components/poInfo_course_supplier'),
        name: 'PolistDetail',
        meta: { title: '分配供应商',activeMenu:'/course_list'  }
      },
      {
        path: '/test',
        component: () => import('@/views/product/test'),
        name: 'Polist',
        meta: { title: 'PO管理列表' }
      },
      {
        path: '/course_list',
        component: () => import('@/views/product/course_list'),
        name: 'Course',
        meta: { title: '课程进度管理' }
      },
      
      {
        path: '/course_supplier_list',
        component: () => import('@/views/product/course_supplier_list'),
        name: 'Suplier',
        meta: { title: '供应商分配总表' }
      },
      {
        path: '/new_contract_management',
        component: () => import('@/views/product/components/contractDetail'),
        name: 'newContract',
        meta: { title: '新合同' }
      },
      {
        path: '/new_settlement_list',
        component: () => import('@/views/product/new_settlement_list'),
        name: 'newContract',
        meta: { title: '新结算单' }
      },
      {
        path: '/supplier_settlement_list',
        component: () => import('@/views/product/supplier_settlement_list'),
        name: 'SuplierAccounts',
        meta: { title: '供应商结算总表' }
      },
  
      {
        path: '/course_warehous_list',
        component: () => import('@/views/product/course_warehous_list'),
        name: 'course_warehous_list',
        meta: { title: '入库课程总揽' }
      }
    ]
  },
  {
    path: '/supplier',
    component: Layout,
    redirect: '/supplier/list',
    name: 'Supplier',
    meta: {
      title: '供应商管理库',
      icon: 'excel'
    },
    children: [
      {
        path: '/supplier_list',
        component: () => import('@/views/supplier/list'),
        name: 'Info',
        meta: { title: '供应商列表' }
      },
   
      
    ]
  },
  
 
  
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
